
package com.hyst.seviceImpl;

import com.hyst.repository.PurchaseCourseViewMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hyst.domain.LessonLevel;
import com.hyst.repository.LessonLevelMapper;
import com.hyst.service.LessonLevelService;
import com.hyst.utils.UuidTool;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Date：2018年08月26日 
 * @author： dy 
 * @version ：1.0 1.[2018年08月26日]
 */
@Service
public class LessonLevelServiceImpl implements LessonLevelService {

	@Autowired
	private LessonLevelMapper mapper;


	@Autowired
	private PurchaseCourseViewMapper purchaseCourseViewMapper;

	@Override
	public Page<LessonLevel> list(final LessonLevel lessonLevel) {
		final Page<LessonLevel> page = PageHelper.startPage(lessonLevel.getPageNum(), lessonLevel.getPageSize());
		mapper.select(lessonLevel);
		for (LessonLevel lessonLevel1 : page.getResult()) {
			Map<String, String> sqlMap = new HashMap<>();
			sqlMap.put("lessonId", lessonLevel1.getLessonId() + "");
			sqlMap.put("levelId", lessonLevel1.getLevelId() + "");
			String lesson = purchaseCourseViewMapper.getSelect2Data(sqlMap);
			lessonLevel1.setText(lesson);
		}
		return page;
	}


	@Override
	public LessonLevel insert(final LessonLevel lessonLevel) {
		mapper.insertSelective(lessonLevel);
		return lessonLevel;
	}

	@Override
	public LessonLevel getByPriKey(final Integer id) {
		final LessonLevel lessonLevel = mapper.selectByPrimaryKey(id);
		return lessonLevel;
	}

	@Override
	public LessonLevel updateSelective(final LessonLevel lessonLevel) {
		mapper.updateByPrimaryKeySelective(lessonLevel);
		return lessonLevel;
	}

	@Override
	public LessonLevel update(final LessonLevel lessonLevel) {
		mapper.updateByPrimaryKey(lessonLevel);
		return lessonLevel;
	}

	@Override
	public LessonLevel delete(final Integer id) {

		return null;
	}

}
